package com.cg.config;

import com.zaxxer.hikari.HikariDataSource;
import io.seata.rm.datasource.DataSourceProxy;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class DataSourceProxyConfig {

    @Bean
    @ConfigurationProperties(prefix = "spring.datasource")
    public HikariDataSource hikariDataSource(){
        return new HikariDataSource();
    }

    @Primary
    @Bean
    public DataSourceProxy dataSource(HikariDataSource hikariDataSource){
        return new DataSourceProxy(hikariDataSource);
    }

}
